home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / misc / newshist.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  1KB  |  81 lines

  1. /*
  2.  * newshist msgids - print history lines corresponding to msgids
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include "news.h"
  7. #include "history.h"
  8.  
  9. char *progname;
  10. int debug;
  11. static char *histfile;        /* unused */
  12. int remote;            /* to satisfy rnews code */
  13. int headdebug = 0;        /* no debugging */
  14.  
  15. /*
  16.  * main - parse arguments and handle options
  17.  */
  18. main(argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.     int c;
  23.     int errflg = 0;
  24.     extern int optind;
  25.     extern char *optarg;
  26.  
  27.     progname = argv[0];
  28.     while ((c = getopt(argc, argv, "df:")) != EOF)
  29.         switch (c) {
  30.         case 'd':
  31.             ++debug;
  32.             break;
  33.         case 'f':
  34.             histfile = optarg;
  35.             break;
  36.         default:
  37.             errflg++;
  38.             break;
  39.         }
  40.     if (optind == argc || errflg) {
  41.         fprintf(stderr, "usage: %s [-df file] msgid ...\n", progname);
  42.         exit(2);
  43.     }
  44.  
  45.     for (; optind < argc; optind++)
  46.         process(argv[optind]);
  47.     exit(0);
  48. }
  49.  
  50. /*
  51.  * process - message-id argument
  52.  */
  53. process(msgid)
  54. char *msgid;
  55. {
  56.     char *histent;
  57.  
  58.     if (msgid == NULL)
  59.         return;        
  60.     histent = gethistory(msgid);
  61.     if (histent == NULL) {
  62.         char newmsgid[1000];
  63.         extern char *strcpy(), *strcat();
  64.  
  65.         (void) strcpy(newmsgid, "<");
  66.         (void) strcat(newmsgid, msgid);
  67.         (void) strcat(newmsgid, ">");
  68.         histent = gethistory(newmsgid);
  69.     }
  70.     if (histent == NULL)
  71.         fprintf(stderr, "%s: no history entry for %s nor <%s>\n",
  72.             progname, msgid, msgid);
  73.     else
  74.         fputs(histent, stdout);
  75.     (void) fflush(stdout);
  76. }
  77.  
  78. unprivileged()
  79. {
  80. }
  81.